
package creature;

public class ShapeTweener
{
	float[]	targets;
	float[]	values;
	
	float speed = 10.0f;

	public ShapeTweener()
	{
	}

	public void init(float[] _values)
	{
		values = new float[_values.length];
		targets = new float[_values.length];

		for (int i = 0; i < _values.length; i++)
		{
			values[i] = _values[i];
			targets[i] = _values[i];
		}
	}
	
	// TODO: make time dependent
	public void tweenTo(float[] _targets, float _speed)
	{
		speed = _speed;
		for (int i = 0; i < _targets.length; i++)
		{
			targets[i] = _targets[i];
		}
	}
	
	public void update()
	{
		for (int i = 0; i < values.length; i++)
		{
			float d = (targets[i]-values[i]) / speed;
			values[i] += d;
		}
	}
	
	public float[] values()
	{
		return values;
	}
}
